package efr.servlet;

import javax.servlet.http.HttpServlet;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Log4jInit extends HttpServlet {
	 private static Logger logger = Logger.getLogger(Log4jInit.class);
	 public void init()
	 {
	     String prefix =  getServletContext().getRealPath("/");
	     logger.debug("prefix: "+prefix);
	     String file = getInitParameter("log4j-init-file");
	  
	     // if the log4j-init-file context parameter is not set, then no point in trying
	     if(file != null){
	      System.setProperty("appRootPath", getServletContext().getRealPath("/"));
	      PropertyConfigurator.configure(prefix+file);
	      System.out.println();
	      logger.debug("Log4J Logging started: " + prefix+file);
	     }
	     else{
	    	 logger.debug("Log4J Is not configured for your Application: " + prefix + file);
	     }     
	 }
	}